package com.yc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.entity.Comment2;
import com.yc.mapper.Comment2Mapper;
import com.yc.service.IComment2Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * InnoDB free: 4096 kB 服务实现类
 * </p>
 *
 * @author ly
 * @since 2022-06-12
 */
@Service
public class Comment2ServiceImpl extends ServiceImpl<Comment2Mapper, Comment2> implements IComment2Service {

    @Resource
    private Comment2Mapper comment2Mapper;

    @Override
    public List<Comment2> queryComment2(Integer cmid) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("cmid", cmid);
        return comment2Mapper.selectList(queryWrapper);
    }

    @Override
    public Integer  insert(Integer uid, String message) {
        Comment2 comment2 = new Comment2();
        comment2.setUid(uid);
        comment2.setMessage(message);
        comment2.setTime(LocalDateTime.now());
        return comment2Mapper.insert(comment2);
    }
}

